/**
 * Copyright 2021 xpstem.com
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.xpstem.lelink.device;

import com.xpstem.lelink.EventBus;
import com.xpstem.lelink.enums.InputPort;

import java.util.HashMap;
import java.util.Map;

/**
 * EV3 color sensor
 *
 * @author billy zhang
 */
public class EV3ColorSensor extends EV3Sensor {

    /**
     * TYPE
     */
    public static final short TYPE = 29;

    /**
     * 反向光强度， 0-100
     */
    public static final short MODE_REFLECTED = 0;
    /**
     * 环境光强度， 0-100
     */
    public static final short MODE_AMBIENT = 1;
    /**
     * 识别颜色， 0：无色，1：黑，2：蓝，3：绿，4：黄，5：红，6：白，7：棕
     */
    public static final short MODE_COLOR = 2;

    public static final short MODE_REFLECTED_RAW = 3;
    public static final short MODE_RGB_RAW = 4;
    public static final short MODE_CALIBRATION = 5;

    private static Map<Short, String> modeMap;
    static {
        modeMap = new HashMap<>();
        modeMap.put(MODE_REFLECTED, "Reflected");
        modeMap.put(MODE_AMBIENT, "Ambient");
        modeMap.put(MODE_COLOR, "Color");
        modeMap.put(MODE_REFLECTED_RAW, "Reflected Raw");
        modeMap.put(MODE_RGB_RAW, "Rgb Raw");
        modeMap.put(MODE_CALIBRATION, "Calibration");
    }

    public EV3ColorSensor(EventBus eventBus, InputPort portNo, short mode) {
        super(eventBus, portNo, "Color Sensor", TYPE, mode);
    }

    @Override
    public Map<Short, String> getModeMap() {
        return modeMap;
    }

}
